import java.util.Scanner;
public class Calculator2 {
        float a,b;
        char n;
        public Calculator2(){
            System.out.println("欢迎使用计算器！");
        }
        public void count(){
            switch(n){
                case '+':
                    System.out.println("和为："+(a+b));
                    break;
                case '-':
                    System.out.println("差为："+(a-b));
                    break;
                case '*':
                    System.out.println("积为："+(a*b));
                    break;
                case '/':
                    if(b!=0){
                        System.out.println("商为："+(a/b));
                    }else{
                        System.out.println("计算错误");
                    }
                    break;
                default:
                    System.out.println("无法进行其他运算");
            }
        }
        public void func2(){
            Scanner scan=new Scanner(System.in);
            System.out.println("请输入第一个数：");
            a=scan.nextFloat();
            System.out.println("请输入运算符：");
            n=scan.next().charAt(0);
            System.out.println("请输入第二个数：");
            b=scan.nextFloat();
            count();
        }

}
